import logging
import os
import time

def Makelog(log_content):
    '''定义日志级别'''
    # 定义日志文件
    logFile = logging.FileHandler(dirname('Rreport.txt'),
                                  'w', encoding='utf-8')
    # 设置log格式
    fmt = logging.Formatter(fmt='%(asctime)s-%(name)s-%(levelname)s-%(module)s:%(message)s')
    logFile.setFormatter(fmt)
    logger1 = logging.Logger('logTest', level=logging.DEBUG)  # 定义日志
    logger1.addHandler(logFile)
    logger1.info(log_content)
    logFile.close()

# Hprint输出成文档
def H5_fileLogSuccess(file):
    '''
    H5游戏，登录成功输入日志
    :param file:
    :return:
    '''
    f_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    k = '   '
    log = open('Log\Log', 'w', encoding='utf-8')
    s = '链接登录成功!'
    name = '\033[1;32m%s\033[0m' % s
    log.write('\n' + f_time + k + file + k + s)
    log.close()

def H5_fileLogError(file):
    '''
        H5游戏，登录失败输入日志
        :param file:
        :return:
        '''
    f_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    k = '   '
    log = open('Log\Log', 'w', encoding='utf-8')
    s = '链接登录失败!'
    name = '\033[1;31m%s\033[0m' % s
    log.write('\n' + f_time + k + file + k + s)
    log.close()


def Unity_fileLogSuccess(file):
    '''
    统一后台验证成功输入日志
    :param file:
    :return:
    '''
    f_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    k = '   '
    z = '账号   '
    log = open('Log\Log', 'a', encoding='utf-8')
    s = '统一后台验证成功!'
    name = '\033[1;32m%s\033[0m' % s
    log.write('\n' + f_time + k + file + z + s)
    log.close()

def Unity_fileLogError(file):
    '''
    统一后台验证失败输入日志
    :param file:
    :return:
    '''
    f_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    k = '   '
    z = '账号   '
    log = open('Log\Log', 'a', encoding='utf-8')
    s = '统一后台验证失败!'
    name = '\033[1;31m%s\033[0m' % s
    log.write('\n' + f_time + k + file + z + s)
    log.close()
if __name__ == '__main__':
    s = 'hello world'
    print('\033[1;32m%s\033[0m' % s)